<h1>Tipos de Documento</h1>

<br/>

<button type="button" class="btn btn-success" id="buttonNuevo"><span class="glyphicon glyphicon-plus"></span> Nuevo</button>

<br/><br/>

<table class="table table-bordered" id="tableList">
    <thead>
        <tr>
            <th>#</th>
            <th>Tipo Documento</th>
            <th>Accion</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $i = 0;
        foreach ($table as $value) {
            $decTipoDocumento = new DecTipoDocumento();
            $decTipoDocumento = $value;
            $i++;

            echo "<tr>";
            echo "<td>{$i}</td>";
            echo "<td>{$decTipoDocumento->getTidDocumento()}</td>";
            echo "<td><button type='button' class='btn btn-xs btn-default' onClick='editar({$decTipoDocumento->getTidId()})'><span class='glyphicon glyphicon-pencil'></span> Editar</button></td>";
            echo "</tr>";
        }
        ?>
    </tbody>
</table>

<script>
    $(document).ready(function() {
        /* DATATABLE */
        $("#tableList").DataTable();
        
        /* LISTENERS */
        $("#buttonNuevo").click(function() {
            $(location).attr("href", "<?php echo url_for("tipo_documento_nuevo/index"); ?>");
        });
    });
    function editar(id) {
        $(location).attr("href", "<?php echo url_for("tipo_documento_editar/index?id="); ?>" + id);
    }
</script>